package org.zhxy.core.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.zhxy.entity.system.Permission;

import java.util.List;

@Mapper
public interface PermissionMapper extends BaseMapper<Permission> {


    @Select("SELECT p.* FROM pe_user u,pe_user_role ur,pe_role r, pe_role_permission rp,pe_permission p WHERE p.id = rp.permission_id AND rp.role_id = r.id AND r.id = ur.role_id AND ur.user_id = u.id AND u.id = #{userId}")
    List<Permission> getPermissionListByUserId(String userId);

    @Select("SELECT p.* FROM pe_permission p, pe_role r, pe_role_permission rp WHERE p.id = rp.permission_id AND rp.role_id = r.id AND r.id = #{roleId}")
    List<Permission> getPermissionListByRoleId(String roleId);
}
